package com.example.mywechatprogram.mapper;

import com.example.mywechatprogram.entity.Word;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;
@Repository
public interface WordMapper {
    @Select("select word,word_id from words where word_bookId=#{bookId} and users_UUID =#{UUID} and word_memorized =0 order by rand() limit 10")
    List<Word>request(@Param("bookId") String bookId, @Param("UUID") String userId);

    @Update("update words set word_memorized=1 where word_id=#{word_id} and users_UUID =#{UUID} and word_bookId=#{bookId}")
    int finish(@Param("word_id") int word_id,@Param("UUID")String userId,@Param("bookId")String bookId);

    @Insert("insert custom_list (word_id,users_UUID,word) values(#{id},#{users_UUID},#{word})")
    int add(@Param("users_UUID") String userId,@Param("word") String word,@Param("id") int word_id);

    @Select("Select word,word_id from custom_list where users_UUID=#{UUID}")
    List<Word>requestCustom(@Param("UUID") String userId);

    @Delete("delete from custom_list where users_UUID=#{UUID} and word_id=#{word_id}")
    int delCustom(@Param("UUID") String userId,@Param("word_id") int word_id);
}
